package com.bice.entity;

import com.bice.dao.IEntity;
import java.util.ArrayList;
import java.util.List;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.*;

@Entity
@Table(name="user")
public class User  implements IEntity {
    
    private Integer id;
    private String code;
    private String nickname;
    private String name;
    
    private List<Post> posts = new ArrayList<Post>();
    private List<Post> postsFrom;
    
    public User() {
    }
	
    public User(String nickname) {
        this.nickname = nickname;
    }
    
    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="id", unique=true, nullable=false)
    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(name="code", nullable=false, length=32)
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    
    @Column(name="nickname", nullable=false, length=16)
    public String getNickname() {
        return this.nickname;
    }
    
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
    
    @Column(name="name", length=32)
    public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="user")
    public List<Post> getPosts() {
        return this.posts;
    }
    
    public void setPosts(List<Post> posts) {
        this.posts = posts;
    }

    @OneToMany(mappedBy = "fromUser")
    public List<Post> getPostsFrom() {
        return postsFrom;
    }

    public void setPostsFrom(List<Post> postsFrom) {
        this.postsFrom = postsFrom;
    }
    
}